from selenium.webdriver import Chrome
import time
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as ec

from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support.wait import WebDriverWait

chrome = Chrome(executable_path="/opt/chromedriver/chromedriver")
chrome.get("https://www.douban.com/")
# print(chrome.window_handles)
movie = chrome.find_element_by_class_name("lnk-movie")
print(chrome.page_source)
# movie.click()
# print(chrome.window_handles)
# chrome.switch_to_window(chrome.window_handles[1])

# try:
#     WebDriverWait(chrome, 10).until(ec.presence_of_element_located((By.CLASS_NAME, "item")))
#     movies = chrome.find_elements_by_class_name("item")
#     for movie in movies:
#         movie_info = movie.find_element_by_tag_name("img")
#         print(movie_info.get_attribute("alt"))
#     # chrome.switch_to_window(chrome.window_handles[0])
#     chrome.switch_to_default_content()
# finally:
#     chrome.quit()


driver = Chrome()
# driver.get("https://www.lagou.com/jobs/list_Python?px=default&city=%E6%88%90%E9%83%BD#filterBox")
# time.sleep(10)
# input_box = driver.find_element_by_id("kw")
# input_box.send_keys("Pig")
# input_box.send_keys(Keys.RETURN)
#
# driver.back()
# time.sleep(2)
# driver.forward()
# time.sleep(2)
#
# driver.back()
# time.sleep(2)
#
# driver.forward()
# time.sleep(2)

# driver.quit()
driver.add_cookie()